home *** CD-ROM | disk | FTP | other *** search
- .Na "dbsqlexec"
- .Aa
- .Fu
- Send a command batch to \*S.
- .Ih "command batch, executing"
- .Ih "command batch, sending to \*S"
- .Sy
- .Sf "RETCODE dbsqlexec(dbproc)"
- .Sp "DBPROCESS" "*dbproc"
- .Co
- .Bl
- This routine sends SQL commands,
- stored in the command buffer of the DBPROCESS,
- to \*S.
- Commands may be added to the DBPROCESS structure by calling
- \f2dbcmd()\f1 or \f2dbfcmd()\f1.
- .Bl
- Once
- .I "dbsqlexec()"
- returns SUCCEED,
- the application must call
- .I "dbresults()"
- to process the results.
- .Bl
- The typical sequence of calls is:
- .ta +4n +4n +4n +4n +4n +4n
- .SD
- .so dbsqlexec.ex
- .ED
- .Bl
- \f2dbsqlexec()\f1 is equivalent to \f2dbsqlsend()\f1 followed by \f2dbsqlok()\f1.
- However, after sending a query to \*S, \f2dbsqlexec()\f1 waits until
- a response is received or until the timeout period has elapsed.
- By substituting \f2dbsqlsend()\f1 and \f2dbsqlok()\f1 for \f2dbsqlexec()\f1,
- you can sometimes provide a way for the application
- to respond more effectively to multiple input and output streams.
- See the manual pages for those two routines for more information.
- .Bl
- An asynchronous version of \f2dbsqlexec()\f1, called \f2dbsqlexec_a()\f1, is available for VMS.
- .Bz
- .Pa
- .Pi dbproc
- A pointer to the DBPROCESS structure that provides the connection
- for a particular front-end/\*S process. It contains all the
- information that \*L uses to manage communications and data between the
- front end and \*S.
- .in -.375i
- .Re
- .br
- SUCCEED or FAIL.
- The most common reason for failing is a SQL syntax error.
- \f2dbsqlexec()\f1 will also fail if there are semantic errors, such as
- incorrect column or table names.
- Failure occurs if \f2any\f1 of the commands in the batch contains a semantic or syntax error.
- \f2dbsqlexec()\f1 also fails if previous results had not been processed, or if
- the command buffer was empty.
- .sp 0.5v
- In addition, a run-time error, such as a database protection violation, will cause \f2dbsqlexec()\f1 to
- fail \f2if\f1 the command buffer contains only a single command.
- If the command buffer contains multiple commands, a run-time error will \f2not\f1 cause \f2dbsqlexec()\f1 to fail.
- Instead, failure will occur with the \f2dbresults()\f1 call that processes the command causing the run-time error.
- .sp 0.5v
- The situation is a bit more complicated for run-time errors and stored procedures.
- A run-time error on an EXECUTE command may cause \f2dbsqlexec()\f1 to fail,
- in accordance with the rule given in the previous paragraph.
- A run-time error on a statement \f2inside\f1 a stored procedure will not cause \f2dbsqlexec()\f1 to fail,
- however.
- For example, if the stored procedure contains an INSERT statement and the user does not have
- insert permission on the database table, the INSERT statement will fail, but \f2dbsqlexec()\f1
- will still return SUCCEED.
- To check for run-time errors inside stored procedures, use the \f2dbretstatus()\f1 routine
- to look at the procedure's return status, and trap relevant \*S messages inside your message handler.
- .Sa
- dbcmd,
- dbfcmd,
- dbnextrow,
- dbresults,
- dbretstatus,
- dbsettime,
- dbsqlexec_a,
- dbsqlok,
- dbsqlsend
-